﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpArch.Domain.DomainModel;

namespace ExBlogger.Domain {
    public class Comment : Entity  {

        protected internal Comment() {
            Content = String.Empty;
            CommentDate = DateTime.Now;
        }

        public virtual int Id { get; protected set; }
        public virtual string Content { get;protected internal set; }
        public virtual DateTime CommentDate { get; protected internal set; }
        public virtual User CommentedBy { get; protected internal set; }
        public virtual Post CommentedOn { get; protected internal set; }

        public virtual Comment On(Post post) {
            if (post.IsTransient())
                throw new InvalidOperationException("Can not comment to an unsaved post.");
            CommentedOn = post;
            return this;
        }
    }
}
